//
//  PropertyViewController.m
//
//  Created by 周成龙
//

#import "PropertyViewController.h"

// -------------------- Person
@interface PropertyPerson : NSObject
{
    NSString *_lastName;
    NSString *_nickName;
}
@property NSString *firstName;
- (NSString *)lastName;
- (void)setLastName:(NSString *)lastName;

@property NSString *nickName;

@end

@implementation PropertyPerson
// @synthesize 自定义实例变量名 （synthesize：合成）
@synthesize firstName = fm;
// Property implementation must have its declaration in interface 'Person' or one of its extensions
// 通过重写 setter和getter的方式生成的属性，不能更改变量名
//@synthesize lastName = lm;

// @dynamic 告诉编译器不要自动创建编译器属性所用的实例变量，也不要为其创建存取方法
@dynamic nickName;

- (NSString *)lastName {
    return _lastName;
}

- (void)setLastName:(NSString *)lastName {
    _lastName = lastName;
}

- (NSString *)nickName {
    return _nickName;
}
- (void)setNickName:(NSString *)nickName {
    _nickName = nickName;
}

@end


// -------------------- PropertyCar
@interface PropertyCar : NSObject

@property (nonatomic, copy) NSString *PropertyPropertyCarName;
@property (nonatomic, copy) NSString *PropertyPropertyCarNickName;
- (NSString *)fullName;
- (void)setFullName:(NSString *)fullName;

@end

@implementation PropertyCar

- (NSString *)fullName {
    return [NSString stringWithFormat:@"%@ %@", _PropertyPropertyCarName, _PropertyPropertyCarNickName];
}

- (void)setFullName:(NSString *)fullName {
    NSArray *array = [fullName componentsSeparatedByString:@" "];
    _PropertyPropertyCarName = array[0];
    _PropertyPropertyCarNickName = array[1];
}

@end


// -------------------- PropertyViewController
@interface PropertyViewController ()

@end

@implementation PropertyViewController
#pragma mark - LifeCycle
- (void)viewDidLoad {
    [super viewDidLoad];
    
    PropertyPerson *p = [[PropertyPerson alloc] init];
    p.firstName = @"zhou";
    p.lastName = @"zak";
    p.nickName = @"Xiao Ming";
    
    NSLog(@"%@", p.nickName);
    
    PropertyCar *c = [PropertyCar new];
    c.fullName = @"马自达 马六";
    
    NSLog(@"%@, %@, %@", c.fullName, c.PropertyPropertyCarName, c.PropertyPropertyCarNickName);
}
@end





